"use strict";
cc._RF.push(module, 'd99bbBY3v1LcJijm4lBn3B0', 'UIPoker');
// script/poker_project/UIPoker.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var ConfigEnum_1 = require("./ConfigEnum");
var GameEvent_1 = require("./gameView/GameEvent");
var SplashScene_1 = require("./SplashScene");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var POINT_MAP = {
    1: "A",
    2: "2",
    3: "3",
    4: "4",
    5: "5",
    6: "6",
    7: "7",
    8: "8",
    9: "9",
    10: "10",
    11: "J",
    12: "Q",
    13: "K"
};
var UIPoker = /** @class */ (function (_super) {
    __extends(UIPoker, _super);
    function UIPoker() {
        // [x: string]: any;
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.pointLabel = null;
        _this.smallSuitSprit = null;
        _this.bigSuitSprit = null;
        _this.bgSprit = null;
        _this.textFrontBG = null;
        _this.textBackBG = null;
        _this.bigSuits = [];
        _this.smallSuits = [];
        _this.texFaces = [];
        _this.redTextColor = cc.color(189, 33, 41);
        _this.blackTextColor = cc.Color.BLACK;
        return _this;
    }
    /*********************************************************************************************
     * 生命周期函数
     *********************************************/
    UIPoker.prototype.start = function () {
        //注册触摸事件
        this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
    };
    UIPoker.prototype.onDestroy = function () {
        this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
        this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
    };
    UIPoker.prototype.Init = function (poker) {
        poker.Bind(this);
        this.pointLabel.string = "" + POINT_MAP[poker.point];
        this.pointLabel.node.color = (poker.suit == ConfigEnum_1.Esuit.HEITAO || poker.suit == ConfigEnum_1.Esuit.MEIHUA) ? this.blackTextColor : this.redTextColor;
        if (poker.point >= 11) {
            this.bigSuitSprit.spriteFrame = this.texFaces[poker.point - 11];
        }
        else {
            this.bigSuitSprit.spriteFrame = this.bigSuits[poker.suit];
        }
        this.smallSuitSprit.spriteFrame = this.smallSuits[poker.suit];
        this.setStatus(poker._status);
    };
    UIPoker.prototype.Rrfresh = function () {
        // this.setStatus();
        // throw new Error("Method not implemented.");
        this.bgSprit.spriteFrame = this.textFrontBG;
        this.pointLabel.node.active = true;
        this.smallSuitSprit.node.active = true;
        this.bigSuitSprit.node.active = true;
    };
    UIPoker.prototype.setStatus = function (status) {
        // return;
        if (status == ConfigEnum_1.EPokerStatus.CLOSE) {
            this.bgSprit.spriteFrame = this.textBackBG;
            this.pointLabel.node.active = false;
            this.smallSuitSprit.node.active = false;
            this.bigSuitSprit.node.active = false;
        }
        else {
            this.bgSprit.spriteFrame = this.textFrontBG;
            this.pointLabel.node.active = true;
            this.smallSuitSprit.node.active = true;
            this.bigSuitSprit.node.active = true;
        }
    };
    /***********************************************************************
     * 事件Event handler
     ***********************************************************************/
    UIPoker.prototype.onTouchStart = function (event) {
        var x = this.node.convertToNodeSpaceAR(event).x;
        console.log('点击事件开始', x);
    };
    UIPoker.prototype.onTouchEnd = function (event) {
        var x = this.node.convertToNodeSpaceAR(event).x;
        SplashScene_1.default.eventTarget.emit(GameEvent_1.default.CLICK_POKER, this.m_Poker);
    };
    UIPoker.prototype.onTouchMove = function (event) {
        var x = this.node.convertToNodeSpaceAR(event).x;
        console.log('点击事件移动', x);
    };
    UIPoker.prototype.onTouchCancel = function (event) {
        var x = this.node.convertToNodeSpaceAR(event).x;
        // this.emit(GameEvent.CLICK_POKER,this.m_Poker)
        console.log('点击事件取消', x);
    };
    __decorate([
        property(cc.Label)
    ], UIPoker.prototype, "pointLabel", void 0);
    __decorate([
        property(cc.Sprite)
    ], UIPoker.prototype, "smallSuitSprit", void 0);
    __decorate([
        property(cc.Sprite)
    ], UIPoker.prototype, "bigSuitSprit", void 0);
    __decorate([
        property(cc.Sprite)
    ], UIPoker.prototype, "bgSprit", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], UIPoker.prototype, "textFrontBG", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], UIPoker.prototype, "textBackBG", void 0);
    __decorate([
        property([cc.SpriteFrame])
    ], UIPoker.prototype, "bigSuits", void 0);
    __decorate([
        property([cc.SpriteFrame])
    ], UIPoker.prototype, "smallSuits", void 0);
    __decorate([
        property([cc.SpriteFrame])
    ], UIPoker.prototype, "texFaces", void 0);
    UIPoker = __decorate([
        ccclass
    ], UIPoker);
    return UIPoker;
}(cc.Component));
exports.default = UIPoker;

cc._RF.pop();